﻿
using System;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;

using AvalonDock.Layout;
using AvalonDock.Themes;

using Poet.ViewModels;

namespace Poet.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
       public MainWindow()
        {
            InitializeComponent();
            new MainViewModel().Bind(this);
            HwndSource.DefaultAcquireHwndFocusInMenuMode = false;
            Keyboard.DefaultRestoreFocusMode = RestoreFocusMode.None;
            // DockingManager.Theme = new VS2010Theme();
        }

        PresentationSource _menuSite;

        private void ToolBarPreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            _menuSite = PresentationSource.FromVisual(this);
            if (_menuSite != null)
            {
                InputManager.Current.PushMenuMode(_menuSite);
                e.Handled = true;
            }        
        }

        private void ToolBarLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            InputManager.Current.PopMenuMode(_menuSite);
            _menuSite = null;
        }
    }
}
